#include "stdafx.h"

#define BAR_WIDTH 10
#define BAR_H_MAX 300

#define AGE_MAX 80
#define AGE_REPRODUCE_MIN 20
#define AGE_REPRODUCE_MAX 35
#define CHILD_PER_PERSON 1.25
#define DELAY 0.02f
#define POP_MAX 1000000

#define FONT_SIZE 9

typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;

struct indiv { unsigned char age, kids; };


struct demograph_list
{
    float bar_ratio;
    sf::RectangleShape bars[AGE_MAX];
    sf::Text text;
    size_t age_group[AGE_MAX];

    size_t
        exponent,
        pop_max,

        deaths_total,
        deaths_this_year,

        births_total,
        births_this_year,

        gen_heirs,

        starting_population,
        pop_total,
        reproducing_people;

    bool run_sim;
    list<indiv> pop;

    void add_indiv(uchar, uchar);
    void init_bars();
    void init();
    void simulation_step();
    void update_bars();
};


struct demograph
{
    sf::RectangleShape bars[AGE_MAX];
    sf::Text text;
    size_t age_group[AGE_MAX];
    float bar_ratio;

    size_t
        current_size,

        exponent,
        pop_max,

        deaths_total,
        deaths_this_year,

        births_total,
        births_this_year,

        gen_heirs,

        starting_population,
        pop_total,
        reproducing_people;

    bool run_sim;
    vector<indiv> pop;
    queue<size_t> repr;
    queue<size_t> dead;

    void init_bars();
    void init();
    void simulation_step();
    void simulation_step2();
    void update_bars();
    void add_indiv(uchar age, uchar kids);
};
